import { http } from '@/utils/http';
import type { Book } from './index.d';

export { Book };

/**  获取专家荐书列表 */
export const getRecommendBookList = (data: Book.RecommendParams) => {
	return http<Book.RecommendData>({
		url: `/api/book/book_list`,
		method: 'POST',
		data,
	});
};

/**  获取专家荐书分类和年级 */
export const getRecommendClassifyGrade = () => {
	return http<Book.RecommendCGData>({
		url: `/api/book/book_classify_grade`,
		method: 'POST',
	});
};

/** 获取图书资源数据 */
export const getBookResource = (data: Book.ResourceParams) => {
	return http<Book.ResourceData>({
		url: `/api/book/book_resource_list`,
		method: 'POST',
		data,
	});
};

/** 获取图书资源分类列表 */
export const getBookResourceClass = (data: Book.ResourceClassParams) => {
	return http<Book.Classify[]>({
		url: `/api/book/book_resource_class_list`,
		method: 'POST',
		data,
	});
};

/** 获取图书详情 */
export const getBookDetails = (data: Book.BookDetailsParams) => {
	return http<Book.BookDetailsData>({
		url: `/api/book/book_info`,
		method: 'POST',
		data,
	});
};

export const getBookDetailsNoLogin = (data: Book.BookDetailsParams) => {
	return http<Book.BookDetailsData>({
		url: `/api/book/get_book_info`,
		method: 'POST',
		data,
	});
};

/**  添加图书到书架 */
export const setBookSelf = (data: Book.BookDetailsParams) => {
	return http({
		url: `/api/book/add_book_self`,
		method: 'POST',
		data,
	});
};

/**  获取用户书架列布奥 */
export const getBookList = (data: Book.BookListParams) => {
	return http<Book.BookListData[]>({
		url: `/api/bookself/student_bookself_list`,
		method: 'POST',
		data,
	});
};

/**  删除用户书架 */
export const delBook = (data: Book.DelParams) => {
	return http({
		url: `/api/bookself/del_student_bookself`,
		method: 'POST',
		data,
	});
};

/**  获取书籍试卷数据 */
export const getPaperInfo = (data: Book.PaperParams) => {
	return http<Book.PaperData>({
		url: `/api/bookexam/get_paper_info`,
		method: 'POST',
		data,
	});
};

/**  提交试卷试题数据 */
export const commitPaperInfo = (data: Book.CommitPaperParams) => {
	return http<Book.CommitPaperData>({
		url: `/api/bookexam/exam_result`,
		method: 'POST',
		data,
	});
};

/**  获取测练结果 */
export const getPaperInfoResult = (data: Book.ResultPaperParams) => {
	return http<Book.ResultPaperData>({
		url: `/api/bookexam/answer_result`,
		method: 'POST',
		data,
	});
};

/**  添加试卷积分 */
export const addPaperInfoPoint = (data: Book.PointPaperParams) => {
	return http({
		url: `/api/bookexam/student_get_integral`,
		method: 'POST',
		data,
	});
};

/**  获取测练答案解析 */
export const getPaperInfoAnalysis = (data: Book.AnalysisPaperParams) => {
	return http<Book.Qtrunk[]>({
		url: `/api/bookexam/answer_analysis`,
		method: 'POST',
		data,
	});
};

export const randomBook = () => {
	return http<any>({
		url: `/api/book/random`,
		method: 'POST'
	});
};
